package 代码记录.Bit48天集训;

import java.util.*;

/**
 * 1.淘宝网店(算是过了吧,自己测试啥的都没问题)
 * 2.斐波那契凤尾(已搞定)
 * @author zx
 * @create 2022-05-31 8:44
 */
public class day_32 {
    /**
     * 没过,算法时间复杂度太大
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int startYear = sc.nextInt();
            int startMonth = sc.nextInt();
            int startDay = sc.nextInt();
            int endYear = sc.nextInt();
            int endMonth = sc.nextInt();
            int endDay = sc.nextInt();
            int[] arr = {2,3,5,7,11};
            Set<Integer> set = new HashSet<>();
            for(int i = 0;i < arr.length;i++){
                set.add(arr[i]);
            }
            int res = 0;
            Calendar c = Calendar.getInstance();
            c.set(Calendar.YEAR,startYear);
            c.set(Calendar.MONTH,startMonth - 1);
            c.set(Calendar.DAY_OF_MONTH,startDay);
            for(;;){
                if(set.contains(c.get(Calendar.MONTH) + 1)){
                    res += 1;
                }else{
                    res += 2;
                }
                c.add(Calendar.DATE, 1);//天数自增1
                if(c.get(Calendar.YEAR) == endYear && (c.get(Calendar.MONTH) + 1) == endMonth &&
                        c.get(Calendar.DAY_OF_MONTH) == endDay){
                    break;
                }
            }
            if(set.contains(c.get(Calendar.MONTH) + 1)){
                res += 1;
            }else{
                res += 2;
            }
            System.out.println(res);
        }
    }

    /**
     * @param args 改进过了(参考了别人的输出)
     */
    public static void main3(String[] args) {
        Scanner sc = new Scanner(System.in);
        Map map = fib2(100000);
        while(sc.hasNext()){
            int n = sc.nextInt();
            if(n > 25){
                System.out.printf("%06d\n",map.get(n));
            }else{
                System.out.println(map.get(n));
            }
        }
    }
    private static Map<Integer,Integer> fib2(int n){
        Map<Integer,Integer> map = new HashMap<>();
        int[] dp = new int[n + 1];
        dp[1] = 1;
        map.put(1,1);
        dp[2] = 2;
        map.put(2,2);
        for(int i = 3;i <= n;i++){
            dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000;
            map.put(i,dp[i]);
        }
        return map;
    }

    /**
     * @param args 第一次写的，时间复杂度太大
     */
    public static void main2(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int n = sc.nextInt();
            if(n > 25){
                System.out.printf("%06d\n",fib(n));
            }else{
                System.out.println(fib(n));
            }
        }
    }
    private static int fib(int n){
        if(n <= 2){
            return n;
        }
        int[] dp = new int[n + 1];
        dp[1] = 1;
        dp[2] = 2;
        for(int i = 3;i <= n;i++){
            dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000;
        }
        return dp[n];
    }
}
